#include "SGNodeRotate.h"
#include "CMatrix.h"
#include "SGTree.h"

SGNodeRotate::SGNodeRotate()
:m_axis(0, CVector3f()), m_angle(0, 0)
{}

//SGNodeRotate::~SGNodeRotate(){}

void SGNodeRotate::doUpdate()
{
	CMatrix rotation;
	CVector3f axis = m_axis;
	if(axis.x == 1)
		rotation.createRotationX(m_angle);
	else if(axis.y == 1)
		rotation.createRotationY(m_angle);
	else
		rotation.createRotationZ(m_angle);

	CMatrix p = SGTREE.getValue();

	SGTREE.setValue(rotation*p); //ROTATION * WORLD
}

void SGNodeRotate::dirty()
{
	m_axis.onChange();
	m_angle.onChange();
}